package com.iflytek.aisol.audit.iflytek.strategy.manage.controller;

import com.iflytek.aisol.audit.iflytek.strategy.manage.dto.ChannelConfigDTO;
import com.iflytek.aisol.audit.iflytek.strategy.manage.entity.ChannelConfig;
import com.iflytek.aisol.audit.iflytek.strategy.manage.query.PageDTO;
import com.iflytek.aisol.audit.iflytek.strategy.manage.query.ServiceVO;
import com.iflytek.aisol.audit.iflytek.strategy.manage.service.ChannelConfigService;
import com.iflytek.aisol.audit.iflytek.strategy.manage.common.entity.R;
import com.iflytek.aisol.audit.iflytek.strategy.manage.query.ChannelPageQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * CLassName: channelConfigController
 * Description:
 * Date: 2024-12-28 16:06
 * Version: 1.0
 * @author hswang7
 */
@RestController
@RequestMapping("/channel-config")
@Slf4j
@Api(tags = "channel配置管理")
public class ChannelConfigController {
    @Autowired
    private ChannelConfigService channelConfigService;

    /**
     * 新增channel配置接口
     */
    @PostMapping
    @ApiOperation(value = "channel 新增配置")
    public R<?> add(@Validated @RequestBody ChannelConfigDTO channelConfigDTO){
        //log.info("插入的数据为：{}", channelConfigDTO);
        channelConfigService.add(channelConfigDTO);
        return R.success();
    }

    @PutMapping("/{id}")
    @ApiOperation(value = "channel 修改配置")
    public R<?> update(@PathVariable Long id,@RequestBody ChannelConfigDTO channelConfigDTO){
        log.info("修改的数据为：{}", channelConfigDTO);
        channelConfigService.update(id,channelConfigDTO);
        return R.success();
    }


    @DeleteMapping("/{id}")
    @ApiOperation(value = "channel 删除配置")
    public R<?> delete(@PathVariable Long id){
        log.info("删除的数据为：{}", id);
        channelConfigService.delete(id);
        return R.success();
    }


    @GetMapping("/page")
    @ApiOperation(value = "channel 分页查询")
    public R<PageDTO<ChannelConfig>> queryPage(ChannelPageQuery query){
        log.info("分页查询的数据为：{}", query);
        PageDTO<ChannelConfig> result = channelConfigService.queryPage(query);
        return R.success(result);
    }
}
